package it.orma.iridehr.jobs;

import java.io.Serializable;

import org.quartz.JobDataMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.CronTriggerBean;


import it.orma.iridehr.repository.ParametriRepository;


public class InitializingCronTrigger extends CronTriggerBean implements Serializable {
    
	@Autowired
	ParametriRepository parametriRepository;
	
    @Override
    public void afterPropertiesSet() throws Exception {
    	super.afterPropertiesSet();
    	System.out.println("*****************PROVA*****************");
    	setCronExpression(parametriRepository.ricercaParametro("EMAIL_CRON_EXPRESSION"));
    	JobDataMap jobDataMap = new JobDataMap();
    	jobDataMap.put("messageWindow", Integer.parseInt(parametriRepository.ricercaParametro("EMAIL_MESSAGE_WINDOW")));
    	setJobDataMap(jobDataMap);
    	setStartDelay(60000);
    	
    }
   
  }
